<template>
  <div>
    <el-dialog title="停车价格设置" :visible.sync="show" width="70%" append-to-body>
      <div>
        <el-table v-loading="loading" :data="dataList" border stripe>
          <el-table-column label="#" type="index" width="80" align="center">
            <template slot-scope="scope">
              <span>{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}</span>
            </template>
          </el-table-column>
          <el-table-column label="会员类型" align="center" min-width="120">
            <template slot-scope="scope">
              <el-tag
                :type="
                  scope.row.settingType == 1
                    ? 'success'
                    : scope.row.settingType == 2
                    ? 'warning'
                    : 'info'
                "
                effect="plain"
              >
                {{
                  scope.row.settingType == 1
                    ? "充电/停车"
                    : scope.row.settingType == 2
                    ? "停车"
                    : "非会员"
                }}
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column
            label="充电类型"
            align="center"
            prop="vehicleTypeName"
            min-width="120"
          />
          <el-table-column
            label="月卡价格"
            align="center"
            prop="monthAmount"
            min-width="120"
          />
          <el-table-column
            label="季卡价格"
            align="center"
            prop="quarterAmount"
            min-width="120"
          />
          <el-table-column
            label="年卡价格"
            align="center"
            prop="yearAmount"
            min-width="120"
          />
        </el-table>
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listVipSetting,
  getVipSetting,
  delVipSetting,
  addVipSetting,
  updateVipSetting,
} from "@/api/weiriya/vipSetting";
export default {
  props: {
    value: {
      type: Boolean,
      default: false,
    },
    // 停车点位ID
    id: {
      type: String,
      default: "",
    },
  },
  computed: {
    show: {
      get() {
        return this.value;
      },
      set() {
        this.$emit("input", false);
      },
    },
  },
  watch: {
    value(val) {
      if (val) {
        this.queryParams.areaId = this.id;
        this.getList();
      }
    },
  },
  data() {
    return {
      loading: false, // 加载状态
      total: 0, // 总条数
      dataList: [], // 数据列表
      queryParams: {
        // 查询参数
        areaId: null,
      },
    };
  },
  methods: {
    // 获取数据
    getList() {
      this.loading = true;
      listVipSetting(this.queryParams)
        .then((res) => {
          this.dataList = res.rows;
          this.total = res.total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
  },
};
</script>

<style lang="scss" scoped></style>
